/**
 * 时序图解析
 */

export default {
  render: ($dom, theme = '') => {
    $dom.find('.markdown-body-sequence-diagram').each(function() {
      let $this = $$(this);

      // 保存时序图内容到 data 属性中
      let text = $this.data('sequence-diagram-text');
      if (!text) {
        text = $this.text();
        $this.data('sequence-diagram-text', text);
      }

      $this.html('');

      // 获取主题
      let d = Diagram.parse(text);
      let options = {
        theme: 'simple'
      };
      d.drawSVG(this, options);
    })
  }
}